<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link href="layui/css/layui.css" rel="stylesheet">
    <style>
        h1{
            background-color: #00f7de;
        }
        .layui-body{
            width: 277px;
            background-color: #c2c2c2;
        }
        #btn{
            position: absolute;
            margin-left: 200px;
            margin-top: -38px;
        }
    </style>
</head>
<script type="application/javascript" src="js/jquery-3.7.1.js"></script>
<script type="application/javascript">
    $(document).ready(function() {
        $('form[action="/game"]').submit(function(event) {
            var yearInput = $('input[name="year"]');
            var yearValue = yearInput.val().trim();

            if (yearValue !== '') {
                yearValue = yearValue.replace(/\D/g, '');
                if (yearValue.length !== 4) {
                    alert('发行年份必须是四位数字！');
                    event.preventDefault();
                }
            }
        });
    });
</script>
<body>
<div class="layui-body">
    <form action="/game">
        <h1>游戏查询</h1>
        <input type="hidden" name="action" value="queryGame">
        <div class="layui-input-group">
            <div class="layui-input-split layui-input-prefix">
                游戏名称
            </div>
            <input type="text" class="layui-input" name="name" value="">
        </div>
        <div class="layui-input-group">
            <div class="layui-input-split layui-input-prefix">
                游戏类型
            </div>
            <input type="text" class="layui-input" name="type" value="">
        </div>
        <div class="layui-input-group">
            <div class="layui-input-split layui-input-prefix" >
                发行公司
            </div>
            <input type="text" class="layui-input"  name="company" value="">
        </div>
        <div class="layui-input-group">
            <div class="layui-input-split layui-input-prefix">
                发行年份
            </div>
            <input type="text" class="layui-input"  name="year" value="">
        </div>

        <input class="layui-btn layui-btn-normal" type="submit" value="查询"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
    </form>
    <button type="button" id="btn" class="layui-btn layui-btn-normal" onclick="window.location.href='addGame.jsp'">新增</button>

</div>
</body>

</html>
